import java.util.*;
import java.math.*;

class TreeNode {
     int val = 0;
     TreeNode left = null;
     TreeNode right = null;

     public TreeNode(int val) {
         this.val = val;
     }
 }
public class test {
    // 牛客 判断是否为平衡二叉树
    public boolean IsBalanced_Solution (TreeNode pRoot) {
        if(pRoot == null){
            return true;
        }
        int l = getG(pRoot.left);
        int r = getG(pRoot.right);
        return (Math.abs(l-r) < 2 && IsBalanced_Solution(pRoot.left) && IsBalanced_Solution(pRoot.right));
    }
    public int getG(TreeNode cur){
        if(cur == null){
            return 0;
        }
        int l = getG(cur.left);
        int r = getG(cur.right);
        return Math.max(l,r) + 1;
    }
    // 牛客 最大子矩阵
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[][] sum = new int[n + 1][n + 1];
        int[][] nums = new int[n + 1][n + 1];
        for(int i = 1;i <= n;i++){
            for(int j = 1;j <= n;j++){
                nums[i][j] = in.nextInt();
            }
        }
        for(int i = 1;i <= n;i++){
            for(int j = 1;j <= n;j++){
                sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + nums[i][j];
            }
        }
        int max = sum[1][1];
        for(int x1 = 1;x1 <= n;x1++){
            for(int y1 = 1;y1 <= n;y1++){
                for(int x2 = x1;x2 <= n;x2++){
                    for(int y2 = y1;y2 <= n;y2++){
                        int num = sum[x2][y2] - sum[x1-1][y2] - sum[x2][y1-1] + sum[x1-1][y1-1];
                        max = Math.max(max,num);
                    }
                }
            }
        }
        System.out.println(max);
    }
    // 牛客 小葱的01串
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = " " + in.next();
        int zero = 0;
        int one = 0;
        char[] nums = s.toCharArray();
        int[] sum = new int[n + 1];
// 前缀和记录某段区间中有几个1
        for (int i = 1; i <= n; i++) {
            sum[i] = sum[i - 1] + (nums[i] - '0');
            if (nums[i] - '0' == 0) {
                zero++;
            } else {
                one++;
            }
        }
        if (zero % 2 != 0 || one % 2 != 0) {
            System.out.println(0);
            return;
        }
        int key = n / 2;
        int num = 0;
        for (int i = 1; (i + key) <= n; i++) {
            int newone = sum[i + key] - sum[i];
            int newzero = key - newone;
            if (newone == one / 2 && newzero == zero / 2) {
                num++;
            }
        }
        int index = 1;
        for (int i = n - key + 1; i <= n; i++, index++) {
            int newone = sum[index] + (sum[n] - sum[i]);
            int newzero = key - newone;
            if (newone == one / 2 && newzero == zero / 2) {
                num++;
            }
        }
        System.out.println(num);
    }
}